package service;

import java.util.HashMap;
import java.util.Map;
import model.User;

public class UserService {
    private Map<String, User> userMap = new HashMap();

    public UserService() {
    }

    public User login(String username, String password) {
        User user = (User)this.userMap.get(username);
        return user != null && user.getPassword().equals(password) ? user : null;
    }

    public void registerUser(User user) {
        this.userMap.put(user.getUsername(), user);
    }

    public void updateUser(User user) {
        this.userMap.put(user.getUsername(), user);
    }
}
